-- card: 3926 from stack: in.9 -- bmap block id: 2139 -- flags: 4000 -- background id: 3627 -- name: Title Card -- part 2 (button) -- low flags: 80 -- high flags: 8003 -- rect: left=98 top=198 right=223 bottom=211 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: load fields ----- HyperTalk script ----- on mouseUp go to card 2 put empty into accum put the number of bkgnd fields into howMany repeat with ii = 1 to howMany put quote & the short name of bkgnd field ii & quote into thingg put the short ID of bkgnd field ii & "," before thingg put thingg into line ii of accum end repeat go to card 1 put accum into card field "field info 1" end mouseUp -- part 12 (field) -- low flags: 80 -- high flags: 4007 -- rect: left=4 top=42 right=235 bottom=512 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: Print Options -- part 14 (button) -- low flags: 00 -- high flags: 8003 -- rect: left=246 top=311 right=333 bottom=367 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Build Print Specs ----- HyperTalk script ----- on mouseUp put "," into comma ask "The Background of which card?" with the number of cards if it is empty then exit mouseUp push card go to card it put empty into accum put the number of cards of this bkgnd into accum ask "Number of columns per page:" with 1 if it is empty then exit mouseUp put comma & it after accum put the number of bkgnd fields into howMany put comma & howMany after accum ask "Gap between records:" with 8 if it is empty then exit mouseUp put comma & it after accum ask "Page Title:" with the short name of this Bkgnd if it is empty then exit mouseUp put comma & it after accum set cursor to 4 repeat with ii = 1 to howMany put the ID of bkgnd field ii into aLine put comma & the rect of bkgnd field ii after aLine put comma & the textFont of bkgnd field ii after aLine put comma & the textSize of bkgnd field ii after aLine put comma & the textHeight of bkgnd field ii after aLine put comma & the textStyle of bkgnd field ii into thingg put comma after aLine put the number of items of thingg into hm if hm>0 then repeat with iii = 1 to hm put char 1 of item iii of thingg after aLine end repeat else put "P" after aLine end if put comma & the textAlign of bkgnd field ii after aLine put ",no," & the short name of bkgnd field ii after aLine put return & aLine after accum end repeat pop card put accum into card field "print options" set the name of bkgnd button ID 4 to "Hide Print Specs" show bkgnd button ID 4 show card field "print options" end mouseUp -- part 15 (button) -- low flags: 00 -- high flags: 8000 -- rect: left=400 top=275 right=326 bottom=470 -- title width / last selected line: 0 -- icon id / first selected line: 1007 / 1007 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: print example ----- HyperTalk script ----- on mouseUp answer "Print or just show output on the screen?" with "Cancel" OR "Print" OR "Show" if it is "Cancel" then exit mouseUp if it is "Show" then put "TUNV" into oKeys else put "TUV" into oKeys end if put card field "print options" of card 1 into specs go to last card -- go to the card to be printed first put the number of cards of this bkgnd into item 1 of specs prFlds "specs",oKeys -- the name of the specs variable must be in quotes go to card 1 end mouseUp -- please note: This button is an example that depends on the print -- specifications being loaded in a card field named "print options" -- of the first card of the stack. The options chosen request a title -- on each page and a line drawn between each record. Also, the version -- number will be shown as the print process begins. To make this -- button work on your stack, you must have your stack designed that way -- or else you will need to somehow get the print -- specifications into a variable (including the number of cards) and -- then pass that variable name as the first argument to prFlds. -- part 16 (field) -- low flags: 81 -- high flags: 0004 -- rect: left=2 top=18 right=341 bottom=510 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: About ----- HyperTalk script ----- on mouseUp hide the target end mouseUp -- part 17 (field) -- low flags: 81 -- high flags: 0007 -- rect: left=11 top=75 right=268 bottom=512 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: layout ----- HyperTalk script ----- on mouseUp hide the target end mouseUp -- part 18 (field) -- low flags: 81 -- high flags: 0007 -- rect: left=3 top=21 right=265 bottom=512 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: selection ----- HyperTalk script ----- on mouseUp hide the target end mouseUp -- part contents for card part 12 ----- text ----- 1,1,14,8,Insurance/Income 17,14,45,294,65,New York,12,16,p,left,no,name 18,316,136,342,153,Palatino,12,16,u,left,no,Bday 19,350,136,376,153,Geneva,12,16,u,left,no,Bmonth 20,384,136,410,153,Geneva,12,16,u,left,no,Byear 21,446,136,472,153,New York,12,16,o,left,no,age 22,377,24,468,39,Geneva,9,12,be,right,no,Client ID 23,467,24,503,39,Geneva,9,12,be,left,no,suffix 24,341,47,503,64,Geneva,12,16,p,left,no,Social Security # 25,15,68,221,118,Geneva,12,16,p,left,no,Address 26,15,121,163,138,Monaco,12,16,p,left,no,Home Phone 27,214,172,362,189,Geneva,12,16,i,left,no,Work Phone 29,15,149,189,166,Geneva,12,16,p,left,no,Insurance 41,39,172,211,189,Geneva,12,16,i,left,no,Employer 43,364,172,461,189,Geneva,12,16,bi,left,no,Income -- part contents for card part 16 ----- text ----- SUGGESTED USE OF THIS STACK: (1) Read the notes here and those shown by clicking on the button "PrFlds Parameter Layout". (2) Copy a card, from a stack you want printed, to the end of this stack. (3) Arrange the fields the way you want then printed on the page (location, size, font, etc.). (4) Return to this card. Click on the "Build Print Specs" button on this card and answer the questions. (5) Make any embellishments to the Specs that you want (see instructions in Parameter Layout text). (6) Click on the "print example" button. (7) Install PrFlds XCMD into your stack, copy the specs field (with contents) and print button into your stack. ABOUT THIS XCMD: PrFlds is an external command (XCMD) that gives general purpose printing capabilities for the content of background fields of a stack. This version (1.9) is limited to 100 fields (or items) per card. PrFlds allows for specification of text areas for each background field. These text areas may be anywhere on the printed page and of any size and the text in the area may be any one of any fonts recognized by the System, any size, style, line height and justification. The text area may also be enclosed by a box. The collection of fields printed from a card (hereafter called a Record) may also be printed in columns on the page. For example, the definitions of the text areas for a record may fit within a space 3.5 inches wide by 3.5 inches high (thus printing in two columns with three records per column). The text printed may be the contents of a background field, any other text, or even the evaluation of a HyperTalk expression (e.g. the long date). The pages of the report produced by PrFlds may also have a title line, including page numbers. Selection criteria can be specified, in the form of a HyperTalk function handler and located in the stack or background script. With this option, a certain subset of the cards of the background may be printed. Click on the button "PrFlds Parameter Layout" for a description of the calling methods of PrFlds. Changes in PrFlds to make version 1.9: a MAJOR bug fix (a problem if more objects were specified than the number of bkgnd fields). Also better error recovery, i.e. if something goes wrong, it should return properly. PRFlds is Copyright © 1988, University of Utah Computer Center (MEB 3440), Salt Lake City, Utah 84112 PrFlds was written by Joseph F. Buchanan at the University of Utah Computer Center and is available for use by anyone provided that proper credit is given for it and its use is not for profit. Inquiries and questions may be directed to me at the University of Utah Computer Center at (801) 581-6802 or AppleLink: A91. -- part contents for card part 17 ----- text ----- PrFlds is VERY general purpose and is therefore somewhat cumbersome in its specifications. Most of the specifications need to be loaded into a variable (container) and the name of the variable is then passed as the first parameter to the XCMD. The second parameter specifies options and the third parameter (if needed) contains the name of a handler (hyperTalk function handler found in the background or stack script). LIMITS: This version of PrFlds (1.9) is limited to 100 objects per record (card) in the report. The options available to PrFlds are as follows: •N - Do not send output to the printer. Instead, show the output on the screen. This will show a test page. •B - Process cards only of this background (of the card showing when PrFlds is invoked). Note: if all cards are processed and different backgrounds are encountered where ANY of the specified fields do not exist for that particular background, an error will occur and the print process will fail. •P - Do a Page Setup dialog. This is useful for specifying page orientation and size. •S - Look for selection criterea in a HyperTalk function (the name of which is in the third parameter). •U - Underline, i.e. draw a line on the page after each record (all fields printed for each card). •V - Show the version of PrFlds. This will appear in a dialog box before printing begins. Example: prFlds "specs","BSUP","ChooseCard(23)" and the "ChooseCard" hyperTalk function handler returning TRUE or FALSE. This feature is described in detail if you click on the "Special Selection Function" button below. The example shown will display a Page Setup dialog before printing. When printing, it will select only those cards of the background satisfy the condition specified in the function ChooseCard. A line will be drawn after each record. The "Specs" information is as follows: • line 1: • item 1: The number of cards to be printed (or examined). This is usually the number of cards of the background or stack. If, instead, you desire to print multiple copies if one record (the contents of the current card), then precede this number by the letter "R". • item 2: The number of columns per page. NOTE - Column boundaries are calculated by dividing the number of columns into the page width. If the size and location parameters of individual fields exceed these boundaries, those areas of the printed page will be overwritten. • item 3: The number of objects to be printed in the record. This includes each field as well as other information that is specified in the subsequent lines of this "Specs" information area. This is usually the number of lines of "Specs" minus 1. • item 4: The size of the gap showing between records (and at the top of the page). • item 5: The title to show at the top of each page. If there is something in this item, even if it is a space character, then a title will be printed, along with a page number, otherwise no title nor page numbers will be printed. • all other lines (one line per object or field): • item 1: Object identification - one of the following: a. The background field ID number (a positive number). OR b. The negative value of a background field ID number - The name of the background field is to be printed instead of its value. OR c. The letter "X" - in this case the text found in item 12 will be evaluated as a HyperTalk expression and used in this place. OR d. The number "0" - The text in item 12 is to be printed as is. NOTE: If item 12 is blank for choices c or d above, then no text will be printed, rather, a line will be drawn connecting the points specified in items 2 and 3 with those in items 4 and 5. • items 2 and 3: The coordinates of the top left corner of the rectangle to contain the text specified in item 1. • items 4 and 5: The coordinates of the bottom right corner of the rectangle to contain the text specified in item 1. NOTE: The coordinates are specified in the same manner as that of the Macintosh screen, i.e. the top left corner of the screen is 0,0 and the bottom right is 512,342. Paper sizes are appropriately larger with the size being approximately 75 dots per inch. PrFlds DOES NOT check to see if page boundaries are exceeded. If you specify areas beyond the physical page, the specified text will not show. Also, note that if a box os to be drawn around a text object, it will appear a few pixels beyond the specified rectangle and can therefore be drawn off the edge of the page. ALSO: As explained in item 1, a line may be drawn from the point defined by items 2 and 3 to the point defined by items 4 and 5. • item 6: The Font name. This can be any font name as recognized by the System. • item 7: The Font size. • item 8: The text height (the height of the line). • item 9: The text style. Use the first letter of the style. Combine as many as you like. These can include: Plain, Bold, Italic, Underline, Outline, Shadow, Extend, Compress. • item 10: The text alignment: Center, Left or Right. • item 11: Border? If yes, then a border is drawn around the text box, otherwise not. • item 12: A text description. This is treated as a comment and ignored unless item 1 is "0" or "X". A button has been programmed on this card to take a card of background fields and construct a print specifications list based on those background fields. You can copy a card from your stack and paste it into this stack and then use the button to see how to construct the print specifications. You may not want the same arrangement of fields in your printed report as is on your card, so you might first re-adjust the location of your fields and eliminate some fields from the constructed list. You may also wish to embellish the record with other objects like field names, additional information and borders. Note: The physical size on the paper of the area to contain the record objects is determined by the rectangles specified for the record objects. The highest number of the item 4 parameters of the objects list is used as the height of the record rectangle. The height of the record plus the record gap will be used to determine how many records can fit on a page. Other Notes: As PrFlds works, it examines all cards, the cards will appear on the screen as they are considered. As the report is being printed, a status is shown in the message window showing the approximate progress (by page number being processed and percent of cards of the stack). This progress is only an approximate and may not be totally accurate. Printing will not actually begin until the entire report is processed. Then if the print does not happen, it may be that there was not enough room on the system disk or in memory to assemble the report (or else that disk was locked). -- part contents for card part 18 ----- text ----- In printing your information from a stack, you may want to extract a subset from the total collection of cards of the background. The third parameter to the PrFlds XCMD will be used to make the determination whether a particular card is to be printed. The following is the method loop of card examination: • a. If the S option is specified, then evaluate the function whose name is found in the third parameter. - if the returned value of the function is FALSE, then ignore the card b. if the S option is not specified, OR if the value returned is TRUE, then process the card. • Go to the next card of this background. The function will usually be a hyperTalk function handler found in the background or stack script, but it might also be something else that returns TRUE or FALSE. An example is as follows: prFlds "specs","S","ChooseCard(23)" function ChooseCard xxx if field age>xxx then return TRUE else return FALSE end if end ChooseCard The card will be chosen if it has a value in the background field AGE of greater than 23. ADDITIONAL INFORMATION: In most cases, a Control-period will terminate the process of printing. Sometimes the XCMD might be in your function if there is some loop problem. Therefore PrFlds was designed to also look for a "Cancel" to be returned from the function and then cancel the entire print process. A use of this is shown below: function ChooseCard xxx if the commandKey is down then -- Note: we cannot check for a period, only the commandKey return "Cancel" exit ChooseCard end if if field age>xxx then return TRUE else return FALSE end if end ChooseCard In this example, if you hold the command key down while the selection function is invoked, the "Cancel" message will be returned to PrFlds and the process will terminate.